﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RpcGenerator.CSharp;
using System.IO;

namespace RpcGenerator.Lua
{
    class LuaRpcGenerator
    {
        public void Generator(Type type, string path, MessageFormatType format)
        {
            MessageDescriptionGenerator mdgenerator = new MessageDescriptionGenerator();
            List<MessageDescription> allDescriptions = mdgenerator.Generate(type);

            DefaultMessageSerializer serializer = new DefaultMessageSerializer(0);
            string proxyFileName = LuaProxyGenerator.Generate(type, serializer, allDescriptions);
            FileGeneratorEx.GenerateLua(Path.Combine(path, proxyFileName), serializer.ToString());

            serializer = new DefaultMessageSerializer(0);
            string invokerFileName = LuaInvokerGenerator.Generate(type, serializer, allDescriptions);
            FileGeneratorEx.GenerateLua(Path.Combine(path, invokerFileName), serializer.ToString());
        }
    }
}
